package com.ljd.server.util;




import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * 日期转换工具类
 *
 * @author ljd on 2022/1/25
 * @PACKAGE_NAME: com.ljd.server.util
 * @PROJECT_NAME: yeb
 */
@Component
public class DateConverter implements Converter<String, LocalDate> {
    @Override
    public LocalDate convert(String s) {

        try{
            return LocalDate.parse(s, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        }catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
